package com.ticket.service.auth.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.ticket.service.auth.domain.UserAccount;
import com.ticket.service.auth.repository.UserAccountRepository;

public class DomainUserDetailsService implements UserDetailsService {

	@Autowired
	UserAccountRepository userAccountRepository;

	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		UserAccount account = userAccountRepository.findUserByName(username);
		if (account == null) {
			System.out.println("用户信息为null");
		}
		return new User(username, account.getPassword(), null);
	}

}
